package com.yubest.common.bean;

import com.yubest.common.consts.Consts;
import org.omg.CORBA.PUBLIC_MEMBER;

import java.io.Serializable;

/**
 * @Author hweiyu
 * @Description
 * @Date 2022/4/19 14:36
 */
public class Response<T> implements Serializable {

    private static final long serialVersionUID = -3077405273608354225L;

    private Integer code;

    private String msg;

    private T data;

    public static <E> Response success() {
        return success(null);
    }

    public static <E> Response success(E data) {
        return new Response<>(Consts.SUCCESS, null, data);
    }

    public static Response error() {
        return error(Consts.ERROR_DESC);
    }

    public static Response error(String msg) {
        return new Response<>(Consts.ERROR, msg, null);
    }

    private Response(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
